#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353,N = 3e5+5;
ll n,k,q;
struct Matrix{
	ll mat[7][7];
}res,now,nnow;
ll val[N][7];
//7种状态:
//(A,B)(B,A)(C,B)(C,A)(A,C)(B,C)(C,C)
//显然C在哪里数量都是一样的，所以直接用一个数代替
//转移:
//      (A,B)         (B,A)         (C,B)               (C,A)             (A,C)             (B,C)             (C,C)
//(A,B) (n-2)(n-3)/2  1             n-2                 0                 n-2               0                 0
//(B,A) 1             (n-2)(n-3)/2  0                   n-2               1                 n-2               0
//(C,B) 1             0             (n-2)(n-3)/2+n-3    1                 0                 1                 n-3
//(C,A) 0             1             1                   (n-2)(n-3)/2+n-3  1                 0                 n-3
//(A,C) 1             0             0                   1                 (n-2)(n-3)/2+n-3  1                 n-3
//(B,C) 0             1             1                   0                 1                 (n-2)(n-3)/2+n-3  n-3
//(C,C) 0             0             1                   1                 1                 1                 (n-2)(n-3)/2+2(n-4)+1 
//遂得矩阵
Matrix operator * (Matrix x,Matrix y)
{
	Matrix res;memset(res.mat,0,sizeof(res.mat));
	for(int i = 0;i < 7;i++)
		for(int j = 0;j < 7;j++)
			for(int k = 0;k < 7;k++)	
				res.mat[i][j] = (res.mat[i][j]+x.mat[i][k]*y.mat[k][j])%mod;
	return res;
}
ll ff(ll x){return (x*(x-1)/2)%mod;}
int lowbit(int x){return x&(-x);}
int a[N];
ll tr[N],tr2[N],Ans[N];
ll iv;
ll qpow(ll x,ll y)
{
    ll res = 1;
    for(;y;y>>=1,x=x*x%mod) if(y&1) res = res*x%mod;
    return res;
}
int main()
{
    //system("fc random.ans random.out");
    freopen("random.in","r",stdin);
    freopen("random.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>k>>q;
	ll t = ff(n-2);
	now=Matrix{{
		{t,1,n-2  ,0    ,n-2  ,0    ,0            },
		{1,t,0    ,n-2  ,0    ,n-2  ,0            },
		{1,0,t+n-3,1    ,0    ,1    ,n-3          },
		{0,1,1    ,t+n-3,1    ,0    ,n-3          },
		{1,0,0    ,1    ,t+n-3,1    ,n-3          },
		{0,1,1    ,0    ,1    ,t+n-3,n-3          },
		{0,0,1    ,1    ,1    ,1    ,t+2*(n-4)+1}}};
	for(int i = 0;i < 7;i++)
		for(int j = 0;j < 7;j++) now.mat[i][j]%=mod;
    nnow = now;
	res.mat[0][0] = 1;
    iv = qpow(n*(n-1)/2%mod,mod-2);
    ll S = qpow(iv,k-q);
	for(int i = k-q;i;i>>=1,now = now*now)
		if(i&1)	res = res*now;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int j = 0;j <= q;j++)
    {
        if(j)
        {
            int x,y;cin>>x>>y;
            swap(a[x],a[y]);
        }
	    for(int i = 1;i <= n;i++)
	    {
	    	ll ls = 0,ms = 0,f = 0,g = 0;
	    	for(int k = a[i];k;k -= lowbit(k)) ls += tr[k],f += tr2[k];
	    	ms = i-ls-1,g = 1ll*i*(i-1)/2-f;
	    	f %= mod,g %= mod;
            int pre[6];
            for(int k = 0;k < 6;k++) pre[k] = val[j][k];
            val[j][0] = (val[j][0] + ms)%mod;
            val[j][1] = (val[j][1] + ls)%mod;
            val[j][2] = (val[j][2] + ls*(n-i)%mod+ms*(i-2)%mod)%mod;
            val[j][3] = (val[j][3] + ls*(n-1)-f+g-ms+mod+mod)%mod;
            val[j][4] = (val[j][4] + f-ls+ms*(n-1)-g+mod+mod)%mod;
            val[j][5] = (val[j][5] + ms*(n-i)%mod+ls*(i-2)%mod+mod)%mod;
	    	for(int k = a[i];k <= n;k += lowbit(k)) tr[k] ++,tr2[k] += i;
	    }
        for(int i = 1;i <= n;i++) tr[i] = tr2[i] = 0;
        val[j][6] = ff(n)*ff(n-2)%mod;
    }
    for(int i = q;i >= 0;i--)
    {
        ll ans = 0;
        for(int j = 0;j < 7;j++)
        {
            ans = (ans + res.mat[j][0]*val[i][j])%mod;
        }
        Ans[i] = ans*S%mod;
        res = nnow*res;
        S = S*iv%mod;
    }
    for(int i = 0;i <= q;i++) cout<<Ans[i]<<"\n";
    return 0;
}